<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../core/include.inc.jsp"%>

<style>
    .pageFormContent p {
        width: 90%;
    }
</style>

<div class="pageContent">
    <form method="post" action="block_edit" class="pageForm required-validate"
          onsubmit="return validateCallback(this, dialogAjaxDone)">

        <div class="pageFormContent nowrap" layoutH="57">

            <p>
                <label>小区名称</label>
                <input type="text" name="blockName" value="${block.blockName}" class="required" maxlength="20" />
            </p>

            <p>
                <label>区县</label>
                <select name="blockArea" class="combox" id="block_area">
                    <option value="杭州">杭州</option>
                    <option value="滨江">滨江</option>
                    <option value="西湖">西湖</option>
                    <option value="上城">上城</option>
                    <option value="下城">下城</option>
                    <option value="拱墅">拱墅</option>
                    <option value="江干">江干</option>
                    <option value="萧山">萧山</option>
                    <option value="余杭">余杭</option>
                    <option value="富阳">富阳</option>
                </select>
            </p>

            <p>
                <label>地址</label>
                <input type="text" name="blockAddr" value="${block.blockAddr}" class="required" maxlength="50" />
            </p>

            <p>
                <label>联系人</label>
                <input type="text" name="blockManager" value="${block.blockManager}" class="required" maxlength="10" />
            </p>

            <p>
                <label>联系电话</label>
                <input type="text" name="blockTel" value="${block.blockTel}" class="required digits" maxlength="11" />
            </p>

            <p>
                <label>小区热线</label>
                <input type="text" name="telephone" value="${block.telephone}" class="" maxlength="20" />
            </p>

            <table width="100%">
                <tr class="text-normal">
                    <td>
                        <label>备注</label>
                        <textarea type="text" name="blockRemark" maxlength="255" cols="60" rows="4">${block.blockRemark}</textarea>
                    </td>
                </tr>
                <tr class="text-normal">
                    <td>
                        <label>图片</label>
                        <div class="image-logo">
                            <img src="${app:getLocalUrl() }/assets/ext/js/uploadify/add_img.png" class="imgList">
                            <input type="file" onchange="upload(0)" class="imgFile"/>
                        </div>
                        <div class="image-logo">
                            <img src="${app:getLocalUrl() }/assets/ext/js/uploadify/add_img.png" class="imgList">
                            <input type="file" onchange="upload(1)" class="imgFile"/>
                        </div>
                        <div class="image-logo">
                            <img src="${app:getLocalUrl() }/assets/ext/js/uploadify/add_img.png" class="imgList">
                            <input type="file" onchange="upload(2)" class="imgFile"/>
                        </div>
                    </td>
                </tr>
            </table>

            <input type="hidden" name="blockImge" class="logo" value="" />
            <input type="hidden" name="blockImge" class="logo" value="" />
            <input type="hidden" name="blockImge" class="logo" value="" />

            <input type="hidden" name="id" class="" value="${block.id}" />

        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent" style="text-align: center;">
                            <button type="submit">保存</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>
<script>

    $('#block_area').val('${block.blockArea}');

    $(function () {

        var imgList = '${block.blockImge}';

        if( imgList != '' ) {
            var array = imgList.split(',');
            for( var i = 0;i<array.length;i++ ) {
                $('.imgList').eq(i).attr('src',array[i]);
                $('.logo').eq(i).val(array[i]);

            }
        }
    });

    // 设置图片地址
    function setImage(index,url) {
        $('.imgList').eq(index).attr('src',url);
        $('.logo').eq(index).val(url);
    }

    function upload(index) {
        uploadImage(index,$('.imgFile').eq(index).get(0).files[0]);
    }

</script>